package java期末作业;

import java.util.ArrayList;
import java.util.Scanner;

public class ArraayLIst {
    public static void main(String[] args) {
        ArrayList<String> strings = new ArrayList<>();
        strings.add("张三");
        strings.add("李四");
        strings.add("王五");
        System.out.println(strings);
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入需要修改的名称:");
        String fruitName = scanner.next();
        int index =strings.indexOf(fruitName);
        System.out.println("当前"+fruitName+ "的下标="+index);
        strings.set(index,"张三丰");
        System.out.println(strings);
        System.out.println("请输入需要删除的对象名称:");
        String fruitNameBtDelete= scanner.next();
        strings.remove("王五");
        System.out.println(strings);

    }
}
